/**
 * @Title: CustomerSeqUtil
 * @Package cn.com.yiqi.wsc.service.customer.common
 * @Description: TODO
 * Copyright: Copyright (c) 2016
 * Company: 成都壹柒互动科技有限公司
 * @author 会员系统组-林威
 * @date 2017/3/20 16:09
 * @version V1.0
 */
package cn.com.yiqi.wsc.service.customer.common;

/**
 *
 *@ClassName: CustomerSeqUtil
 * Description: TODO
 * @author 会员系统组-林威
 * @date 2017/3/20 16:09
 *
 */
public class CustomerSeqUtil {

    /**
     * @Param seq
     * @Return 层级
     * */
    public static Integer seqLevel(String seq){
        return seq.split("\\u002E").length - 2;
    }

    /**
     * 设置seq
     * */
    public static String setSeq(String seq,Integer pid){
        seq = seq+pid+".";
        //层级码只保留五位
//        while(seqLevel(seq) > 5){
//            seq = seq.substring(seq.indexOf(".",1));
//        }
        return seq;
    }




    public static void main(String[] args) {
        System.out.println(seqLevel(".0.1.3.4.12313."));
        System.out.println(getId(".0.1.3.4.12313.",4));
    }

    /**
     * 获取seq的第index级的id
     * */
    public static Integer getId(String seq, Integer index) {
        while (index > 0){
            seq = seq.substring(0,seq.lastIndexOf("."));
            index--;
        }
        return Integer.parseInt(seq.substring(seq.lastIndexOf(".")+1,seq.length()));
    }
}
